using System.IO;
using UnityEngine;

//写入器
public class GameDataWriter
{
    

    BinaryWriter writer;

    public GameDataWriter(BinaryWriter writer)
    {
        this.writer = writer;
    }

    public void Write(float value)
    {
        writer.Write(value);
    }
    public void Write(int value)
    {
        writer.Write(value);
    }
    public void Write(Quaternion value)
    {//Quaternion 四元数 用于旋转
        writer.Write(value.x);
        writer.Write(value.y);
        writer.Write(value.z);
        writer.Write(value.w);
    }
    public void Write(Vector3 value)
    {
        writer.Write(value.x);
        writer.Write(value.y);
        writer.Write(value.z);
    }
    public void Write(Color value)
    {//保存颜色
        writer.Write(value.r);
        writer.Write(value.g);
        writer.Write(value.b);
        writer.Write(value.a);
    }

    public void Write(Random.State value)
    {//保存随机种子
        //Random.State包含四个浮点数，但不能公开访问，所以序列化后保存
        writer.Write(JsonUtility.ToJson(value));
    }
}